#!./common/bats/bin/bats
# -*-sh-*-

load ./common/test_helper_functions || exit 1
source ./common/functions || exit 1

if [ -s ./common/TEST_ENV ];then
    source ./common/TEST_ENV
fi

check_rms
rm=$RESOURCE_MANAGER
testname="libs/MFEM"

NODES=2
TASKS=8

@test "[$testname] p_laplace MPI binary runs under resource manager ($rm/$LMOD_FAMILY_COMPILER/$LMOD_FAMILY_MPI)" {
    binary=p_laplace
    if [ ! -x $binary ];then
	flunk "$binary binary does not exist"
    fi

    run_mpi_binary ./${binary} "-no-vis" $NODES $TASKS 
    assert_success
}

@test "[$testname] p_laplace_perf MPI binary runs under resource manager ($rm/$LMOD_FAMILY_COMPILER/$LMOD_FAMILY_MPI)" {
    binary=p_laplace_perf
    if [ ! -x $binary ];then
	flunk "$binary binary does not exist"
    fi

    run_mpi_binary ./${binary} "-no-vis -rs 2" $NODES $TASKS 
    assert_success
}

@test "[$testname] p_cantilever MPI binary runs under resource manager ($rm/$LMOD_FAMILY_COMPILER/$LMOD_FAMILY_MPI)" {
    binary=p_cantilever
    if [ ! -x $binary ];then
	flunk "$binary binary does not exist"
    fi

    run_mpi_binary ./${binary} "-no-vis" $NODES $TASKS 
    assert_success
}

@test "[$testname] p_diffusion MPI binary runs under resource manager ($rm/$LMOD_FAMILY_COMPILER/$LMOD_FAMILY_MPI)" {
    binary=p_diffusion
    if [ ! -x $binary ];then
	flunk "$binary binary does not exist"
    fi

    run_mpi_binary ./${binary} "-no-vis" $NODES $TASKS 
    assert_success
}
